 /*
    MegaShorter, the ultimate url-shorting tool
    Copyright (C) 2011  Ivan I. Kolesnikov

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef MANAGER_H
#define MANAGER_H

#include <QApplication>
#include <QObject>
#include <QSystemTrayIcon>
#include <QClipboard>
#include <QMenu>
#include <QUrl>
#include <QSettings>
#include <QList>
#include <QDateTime>
#include <QSettings>
#include <QSharedPointer>
#include <QDir>
#include <QFile>
#include <QDesktopServices>

#include <QtDebug>

#include "shorters/shorterfactory.h"

class Manager : public QObject
{
    Q_OBJECT

public:
    explicit Manager(QObject *parent = 0);

private:
    QDateTime clipboardTempDT;
    QScopedPointer<ShorterFactory> factory;
    QScopedPointer<QSystemTrayIcon> tray;
    QSharedPointer<QSettings> settings;
    QScopedPointer<QMenu> mainMenu;
    QScopedPointer<QActionGroup> servicesGroup;
    QSharedPointer<Shorter> currentShorter;

    QAction *clipboardAction;
    QAction *saveLinksAction;
    //QAction *useRegSvcsAction;

    void createMenus();
    void doShort(const QString &s);
    void saveLink(const QString &shortUrl, const QString &longUrl);

private slots:
    void exitAction();
    void settingsChanged();
    void trayActivated(QSystemTrayIcon::ActivationReason reason);
    void clipboardChanged();
    void shorterDone(int status, QString req, QString msg);
};

#endif // MANAGER_H
